//
//  CXEmotionPopView.swift
//  Project03-Weibo-swift
//
//  Created by w on 16/1/30.
//  Copyright © 2016年 w. All rights reserved.
//

import UIKit

class CXEmotionPopView: UIView {
    
    @IBOutlet weak var popBtn: CXEmotionButton!
    
    ///  快速创建 类方法
    class func popView() -> CXEmotionPopView {
        
        return NSBundle.mainBundle().loadNibNamed("CXEmotionPopView", owner: nil, options: nil).last! as! CXEmotionPopView
    }
    
    func display(button: CXEmotionButton) {
        //nil：该参数默认值为 window
        let rect = button.superview!.convertRect(button.frame, toView: nil)
        
        self.center.x = CGRectGetMidX(rect)
        self.frame.origin.y = CGRectGetMaxY(rect) - self.frame.height
        self.popBtn.emotion = button.emotion //通过赋给它模型 模型的didSet方法来赋予内容
    }

}
